package hottargui.gui;

import hottargui.framework.Game;
import hottargui.view.DieFigure;
import hottargui.view.ToolDecorator;
import minidraw.framework.*;
import java.awt.event.MouseEvent;

public class RollDieToolDecorator extends ToolDecorator {
	
	public RollDieToolDecorator(DrawingEditor editor, Game game, Tool decoratedTool)
	{
		super(editor, game, decoratedTool);
		
		decoratee = decoratedTool;
		this.game = game;
	}
	
	public void mouseDown(MouseEvent e, int x, int y) {
		Drawing model = editor().drawing();
		Figure figureUnderCursor = model.findFigure(x, y);
		if ( figureUnderCursor instanceof DieFigure)
		{
			game.rollDie();
		}
		else
		{
			decoratee.mouseDown(e, x, y);
		}
	}
}
